/* SGATOR
 * boundvar.h
 */

#ifndef SGBOUNDVAR_H
#define SGBOUNDVAR_H

#include "base.h"

#define SG_BOUND_MODE_FORWARD 1
#define SG_BOUND_MODE_BACKWARD 2
#define SG_BOUND_MODE_DOUBLE 3

typedef void (*SgBVarFun)(SgVal *d, SgVal *s);

typedef struct _SgBoundVar {
  SgVal *val;
  SgBool lst;
  SgStack *ivars;
  SgStack *ovars;
  SgBVarFun on_setvar;
  SgBVarFun on_varset;
} SgBoundVar;

SgBoundVar *sg_make_bvar(SgVal *val);
void sg_init_bvar(SgBoundVar *bvar, SgVal *val);
void sg_free_bvar(SgBoundVar *bvar);
void sg_bound_bvars(SgBoundVar *v0, SgBoundVar *v1, SgInt mode);
void sg_unbound_bvars(SgBoundVar *v0, SgBoundVar *v1, SgInt mode);
void sg_unbound_bvar(SgBoundVar *bvar);
void sg_set_bvar(SgBoundVar *bvar, SgVal val, SgBVarFun on_setvar);

#endif

/* end */

